package View.Menu;

import java.awt.Graphics;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JFrame;

import Controller.Menu.MenuController;
import Utils.ConstantsImplement;
import View.General.ComponentPanel;

public class MenuPanel extends ComponentPanel implements ConstantsImplement{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private BufferedImage imageBackground;
	private MenuController menuController_;
	private JButton startButton_;
	private JButton quitButton_;
	private JButton optionButton_;
	private JButton controls_;
	
	public MenuPanel(JFrame frame, MenuController menuController){
		this.setLayout(null);
		
		menuController_ = menuController;
		// instancing
		startButton_ = new JButton();
		quitButton_ = new JButton();
		optionButton_ = new JButton();
		controls_ = new JButton();
		
		
		// pointing 
		startButton_.setLocation(MENU_BUTTON_LOCATION_RATE_X, MENU_BUTTON_FIRST_LOCATION_Y);
		controls_.setLocation(MENU_BUTTON_LOCATION_RATE_X, startButton_.getY() + MENU_BUTTON_DISTANCE_Y);
		optionButton_.setLocation(MENU_BUTTON_LOCATION_RATE_X, controls_.getY() + MENU_BUTTON_DISTANCE_Y);
		quitButton_.setLocation(MENU_BUTTON_LOCATION_RATE_X, optionButton_.getY() + MENU_BUTTON_DISTANCE_Y);
		
		// sizing
		startButton_.setSize(MENU_BUTTON_RATE_W, MENU_BUTTON_RATE_H);
		quitButton_.setSize(MENU_BUTTON_RATE_W, MENU_BUTTON_RATE_H);
		optionButton_.setSize(MENU_BUTTON_RATE_W, MENU_BUTTON_RATE_H);
		controls_.setSize(MENU_BUTTON_RATE_W, MENU_BUTTON_RATE_H);
		
		// 
		startButton_.setText("Start");
		quitButton_.setText("Quit");
		controls_.setText("Controls");
		optionButton_.setText("Credits");
		
		// Graphing
		
		//adding image
		
		imageBackground = menuController_.getMedia_().imageBackground;
		
		this.add(startButton_);
		this.add(quitButton_);
		this.add(optionButton_);
		this.add(controls_);
		
	}
	public void paintComponent(Graphics g){
		super.paintComponent(g);
		g.drawImage(imageBackground, 0, 0, getWidth(), getHeight(), null);
	}
	
	public void addStartButtonActionListener(ActionListener start){
		System.out.println(MENU_BUTTON_RATE_W*getWidth());
		startButton_.addActionListener(start);
	}
	
	public void addOptionButtonActionListener(ActionListener option){
		optionButton_.addActionListener(option);
	}
	
	public void addQuitButtonActionListener(ActionListener quit){
		quitButton_.addActionListener(quit);
	}
	

	public void addControlsActionListener(ActionListener quit){
		controls_.addActionListener(quit);
	}
	
}
